package com.coda.mapper;

import com.coda.entity.ProductType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProductTypeMapper {
    /**
     * 查询所有分类
     * @return
     */
    @Select("select * from product_type")
    List<ProductType> getProductTypeList();

    /**
     * 根据分类编码查询分类方法
     * @param typeCode
     * @return
     */
    @Select("select * from product_type where type_code = #{typeCode}")
    ProductType getProductTypeByCode(String typeCode);

    /**
     * 添加商品分类
     * @param productType
     */
    void addProductType(ProductType productType);

    /**
     * 根据id删除分类
     * @param id
     */
    @Delete("delete from product_type where type_id = #{id} or parent_id = #{id}")
    void deleteById(Long id);

    /**
     *
     * @param productType
     */
    void update(ProductType productType);
}
